// 用户基础信息
export interface User {
  id: string;
  username: string;
  email: string;
  phone?: string;
  avatar?: string;
  status: "active" | "inactive" | "suspended";
  isPremium: boolean;
  roles: string[];
  createdAt: string;
  updatedAt: string;
  lastLoginAt?: string;
}

// 用户详细资料
export interface UserProfile {
  id: string;
  userId: string;
  displayName?: string;
  bio?: string;
  avatar?: string;
  cover?: string;
  location?: string;
  website?: string;
  birthday?: string;
  gender?: "male" | "female" | "other" | "prefer_not_to_say";
  timezone?: string;
  language: string;
  preferences: UserPreferences;
  socialLinks?: {
    twitter?: string;
    github?: string;
    linkedin?: string;
    instagram?: string;
  };
  stats: {
    totalSessions: number;
    totalMessages: number;
    joinDate: string;
    lastActiveDate: string;
  };
  createdAt: string;
  updatedAt: string;
}

// 用户偏好设置
export interface UserPreferences {
  theme: "light" | "dark" | "auto";
  language: string;
  fontSize: "small" | "medium" | "large";
  soundEnabled: boolean;
  notificationEnabled: boolean;
  autoSave: boolean;
  chatBubbleStyle: "classic" | "modern" | "minimal";
  showTypingIndicator: boolean;
  enableMarkdown: boolean;
  compactMode: boolean;
  showTimestamps: boolean;
  groupMessagesByDate: boolean;
  enableAnimations: boolean;
  highContrastMode: boolean;
  reduceMotion: boolean;
}

// 登录请求
export interface LoginRequest {
  username: string;
  password: string;
  rememberMe?: boolean;
  captcha?: string;
  twoFactorCode?: string;
}

// 注册请求
export interface RegisterRequest {
  username: string;
  email: string;
  password: string;
  confirmPassword: string;
  inviteCode?: string;
  captcha?: string;
  verificationCode?: string;
  agreeToTerms: boolean;
  subscribeNewsletter?: boolean;
}

// 登录响应
export interface LoginResponse {
  token: string;
  refreshToken: string;
  user: User;
  roles: string[];
  permissions: string[];
  expiresIn: number;
  requiresTwoFactor?: boolean;
}

// 注册响应
export interface RegisterResponse {
  user: User;
  message: string;
  autoLogin: boolean;
  token?: string;
  refreshToken?: string;
  requiresEmailVerification?: boolean;
}

// 用户统计信息
export interface UserStats {
  totalSessions: number;
  totalMessages: number;
  totalTokensUsed: number;
  favoritePersonas: string[];
  joinDate: string;
  lastActiveDate: string;
  usageToday: number;
  usageThisMonth: number;
  streakDays: number;
  achievements: UserAchievement[];
}

// 用户成就
export interface UserAchievement {
  id: string;
  name: string;
  description: string;
  icon: string;
  category: "chat" | "persona" | "social" | "milestone";
  rarity: "common" | "rare" | "epic" | "legendary";
  unlockedAt: string;
  progress?: {
    current: number;
    target: number;
  };
}

// 用户使用历史
export interface UserUsageHistory {
  date: string;
  sessions: number;
  messages: number;
  tokensUsed: number;
  averageSessionLength: number;
  mostUsedPersona?: string;
}

// 用户通知设置
export interface NotificationSettings {
  emailNotifications: boolean;
  pushNotifications: boolean;
  smsNotifications: boolean;
  marketingEmails: boolean;
  securityAlerts: boolean;
  chatNotifications: boolean;
  personaUpdates: boolean;
  weeklyDigest: boolean;
  mentionNotifications: boolean;
  followNotifications: boolean;
}

// 用户隐私设置
export interface PrivacySettings {
  profileVisibility: "public" | "friends" | "private";
  showOnlineStatus: boolean;
  allowDirectMessages: boolean;
  shareUsageStats: boolean;
  dataCollection: boolean;
  showInSearch: boolean;
  allowPersonaSharing: boolean;
  showAchievements: boolean;
}

// 用户订阅信息
export interface UserSubscription {
  plan: "free" | "premium" | "pro";
  status: "active" | "cancelled" | "expired" | "past_due";
  startDate: string;
  endDate?: string;
  renewalDate?: string;
  features: string[];
  usage: {
    messagesUsed: number;
    messagesLimit: number;
    tokensUsed: number;
    tokensLimit: number;
    personasUsed: number;
    personasLimit: number;
    storageUsed: number;
    storageLimit: number;
  };
  billing: {
    amount: number;
    currency: string;
    interval: "monthly" | "yearly";
    nextPayment?: string;
  };
}

// 用户邀请信息
export interface UserInvite {
  code: string;
  usageCount: number;
  maxUsage: number;
  expiresAt?: string;
  createdAt: string;
  rewards: {
    inviter: string;
    invitee: string;
  };
}

// 邀请历史记录
export interface InviteHistory {
  inviteeUsername: string;
  inviteDate: string;
  status: "pending" | "accepted" | "expired";
  reward?: string;
  bonusEarned?: number;
}

// 用户标签
export interface UserTag {
  id: string;
  name: string;
  color: string;
  count: number;
  createdAt: string;
}

// 用户会话信息
export interface UserSession {
  id: string;
  ip: string;
  userAgent: string;
  location?: {
    country: string;
    city: string;
    region: string;
  };
  device: {
    type: "desktop" | "mobile" | "tablet";
    os: string;
    browser: string;
  };
  lastActivity: string;
  current: boolean;
  createdAt: string;
}

// 登录历史记录
export interface LoginHistory {
  id: string;
  ip: string;
  userAgent: string;
  location?: {
    country: string;
    city: string;
    region: string;
  };
  loginTime: string;
  success: boolean;
  failureReason?: string;
  twoFactorUsed?: boolean;
}

// 分页响应类型
export interface PageResponse<T> {
  content: T[];
  totalElements: number;
  totalPages: number;
  size: number;
  number: number;
  first: boolean;
  last: boolean;
  empty: boolean;
  sort: {
    sorted: boolean;
    unsorted: boolean;
    empty: boolean;
  };
}

// 用户搜索结果
export interface UserSearchResult {
  id: string;
  username: string;
  displayName?: string;
  avatar?: string;
  bio?: string;
  isFollowing?: boolean;
  mutualFriends?: number;
  lastActive?: string;
}

// 用户关系
export interface UserRelation {
  id: string;
  userId: string;
  targetUserId: string;
  type: "follow" | "friend" | "block" | "mute";
  status: "pending" | "accepted" | "rejected";
  createdAt: string;
  updatedAt: string;
}

// 用户活动记录
export interface UserActivity {
  id: string;
  userId: string;
  type:
    | "login"
    | "logout"
    | "chat"
    | "persona_create"
    | "persona_share"
    | "achievement";
  description: string;
  metadata?: Record<string, any>;
  createdAt: string;
}

// 用户反馈
export interface UserFeedback {
  id: string;
  userId: string;
  type: "bug" | "feature" | "improvement" | "complaint" | "praise";
  title: string;
  content: string;
  category: string;
  priority: "low" | "medium" | "high" | "urgent";
  status: "open" | "in_progress" | "resolved" | "closed";
  attachments?: string[];
  response?: string;
  createdAt: string;
  updatedAt: string;
}
